//
//  myTabBarViewController.m
//  CustomTabBar
//
//  Created by giantumbrella on 15/5/20.
//  Copyright (c) 2015年 zhaojuan. All rights reserved.
//

#import "myTabBarViewController.h"
#import "HomeViewController.h"
#import "DoorViewController.h"
#import "EvaluationViewController.h"
#import "MyFamilyController.h"
#import "SetOutViewController.h"//我的~~
#import "MyFamilyViewController.h"
#import "SetOutDoorController.h"//新的

@interface myTabBarViewController ()

@end

@implementation myTabBarViewController

- (void)viewDidLoad {
    
    
    [super viewDidLoad];
     self.view.backgroundColor = [UIColor whiteColor];
    [self setupAllChildViewControllers];
    
    
}



-(void)setupAllChildViewControllers{
    
    //1.首页
    HomeViewController *homeView = [[HomeViewController alloc] init];
    homeView.type = self.type;
    homeView.showPg = self.showPg;
    [self setupChildViewController:homeView title:@"首页" imageName:@"home" selectedImageName:@"homeSelected"];

    //2.测评
    EvaluationViewController *evaluationView = [[EvaluationViewController alloc]init];
    [self setupChildViewController:evaluationView title:@"观察" imageName:@"evaluation" selectedImageName:@"evaluationSelected"];
    
    //3.上门早教
    DoorViewController *establishView = [[DoorViewController alloc]init];
    [self setupChildViewController:establishView title:@"上门早教" imageName:@"door" selectedImageName:@"doorSelected"];
    
    //4.出发
    SetOutDoorController *setOutView = [[SetOutDoorController alloc] init];
    [self setupChildViewController:setOutView title:@"出发" imageName:@"senOut" selectedImageName:@"senOutSelected"];
    
    //5.我家
    MyFamilyViewController *infomationView = [[MyFamilyViewController alloc] init];
    [self setupChildViewController:infomationView title:@"我家" imageName:@"myFamily" selectedImageName:@"myFamilySelected"];
}

//初始化一个子控件
- (void)setupChildViewController:(UIViewController *)childVC title:(NSString *)title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName
{

//1.设置控件属性
    childVC.title = title;
    
    

    
    if ([[[UIDevice currentDevice] systemVersion] floatValue] <= 7.1) {
        
        [childVC.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:selectedImageName] withFinishedUnselectedImage:[UIImage imageNamed:imageName]];
        
    } else {
        
        childVC.tabBarItem.image = [UIImage imageNamed:imageName];
        childVC.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    }
    
    //2.包装一个导航栏
    UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:childVC];
    
    

    [self addChildViewController:navi];
}


@end
